package xiaohu.day5.HJ55;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()) {
            int n = scanner.nextInt();
            int count = 0;
            for (int i = 1; i <=n; i++) {
                boolean flag=isContain7(i);
                if (flag) {
                    count++;
                } else {
                    if (i % 7 == 0) {
                        count++;
                    }
                }
            }
            System.out.println(count);
        }
    }

    private static boolean isContain7(int m) {
        while (m > 0) {
            int remainder = m % 10;
            if (remainder == 7) {
                return true;
            } else {
                m = m / 10;
            }
        }
        return false;
    }
}
